#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
    int year = 0;
    int month = 0;
    int date = 0;
    scanf("%d %d %d", &year, &month, &date);
    int month_count[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

    if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
        month_count[1]++;
    int sum = 0;
    int days = 0;
    for (int i = 1; i < month; i++)
    {
        if (month < 2)
        {
            days = date;
        }
        else
        {
            sum += month_count[i - 1];
        }
    }
    days = sum + date;
    printf("%d\n", days);
    return 0;
}